#include <iostream>
#include <vector>
using namespace std;
int n, m;
int main()
{
    cin >> n >> m;
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
    vector<vector<char>> grid(n + 1, vector<char>(m + 1, 0));
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> grid[i][j];
        }
    }
    int ret = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {

            int tem = 0;
            char c = grid[i][j];
            if (c == 'l')
                tem += 4;
            else if (c == 'o')
                tem += 3;
            else if (c == 'v')
                tem += 2;
            else if (c == 'e')
                tem += 1;
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + tem;
            // printf("(%d,%d):%d %d ",i,j,dp[i][j],tem);
            ret = max(ret, dp[i][j]);
        }
        // cout<<endl;
    }
    cout << ret << endl;
}
// 64 位输出请用 printf("%lld")